summaryrefslogtreecommitdiff
path: root/src/app/api/product/[id]/toggle-different/route.tsx
blob: 987dbf3774fe7f790da507824cdc78c85a67233a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { NextRequest, NextResponse } from "next/server";
import { prisma } from "prisma/client";

type Params = { params: { id: string } }
export async function POST(request: NextRequest, { params }: Params) {
  const intId = parseInt(params.id)
  const product = await prisma.product.findUnique({ where: { id: intId } })
  const updatedProduct = await prisma.product.update({
    where: { id: intId },
    data: {
      isDifferent: !product?.isDifferent
    }
  })

  return NextResponse.json(updatedProduct)
}